package com.qiyuexinxi.chat.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 资源映射路径
 */
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {

    //上传后的服务器路径
    @Value("${web.upload-path}")
    public String filePath;
    //url访问路径
    @Value("${web.domain-name-addresses}")
    public String domainNameAddresses;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(domainNameAddresses+"**").addResourceLocations("file:"+filePath);
    }
}
